﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Web.Configuration;
using System.Data.Sql;
using System.Data;
using WebApplication1.bll;

namespace WebApplication1.dao
{
    public class conexao : Icadastro
    {
        string mensagem;

        public string conexaocadasto(string nome, string email, string senha)
        {


            String conexString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["wallet"].ConnectionString;
            System.Data.SqlClient.SqlConnection conexao = new System.Data.SqlClient.SqlConnection(conexString);
            System.Data.SqlClient.SqlCommand comando = new System.Data.SqlClient.SqlCommand();
            comando.Connection = conexao;
            comando.CommandType = System.Data.CommandType.Text;
            comando.CommandText = "insert into cadastro(nome,email,senha) values('" + nome + "','" + email + "','" + senha + "')";
            conexao.Open();
            comando.ExecuteNonQuery();
            conexao.Close();
            return mensagem = "Cadastro realizado com sucesso";
        }

        public int buscaemail(string email)
        {
            string linkemail = WebConfigurationManager.ConnectionStrings["wallet"].ConnectionString;
            SqlConnection conexaoemail = new SqlConnection(linkemail);
            SqlCommand execucao = new SqlCommand();
            execucao.Connection = conexaoemail;
            execucao.CommandType = System.Data.CommandType.Text;
            execucao.CommandText = "select count(email) from cadastro where email='" + email + "'";
            conexaoemail.Open();
            int registro = (int)execucao.ExecuteScalar();
            conexaoemail.Close();
            return registro;

        }

    

    }
}